home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / whoisx / WHOCOM5.FRM < prev    next >
Text File  |  1998-11-17  |  10KB  |  316 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "WhoIs/X COM Sample"
  4.    ClientHeight    =   7920
  5.    ClientLeft      =   1980
  6.    ClientTop       =   1500
  7.    ClientWidth     =   6945
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   7920
  11.    ScaleWidth      =   6945
  12.    Begin VB.CheckBox Check1 
  13.       Caption         =   "Use Fast Notifications"
  14.       Height          =   255
  15.       Left            =   5040
  16.       TabIndex        =   13
  17.       Top             =   600
  18.       Width           =   1935
  19.    End
  20.    Begin VB.ListBox List1 
  21.       Height          =   1230
  22.       Left            =   240
  23.       TabIndex        =   8
  24.       Top             =   6600
  25.       Width           =   6495
  26.    End
  27.    Begin VB.TextBox Text1 
  28.       BeginProperty Font 
  29.          Name            =   "Courier New"
  30.          Size            =   8.25
  31.          Charset         =   0
  32.          Weight          =   400
  33.          Underline       =   0   'False
  34.          Italic          =   0   'False
  35.          Strikethrough   =   0   'False
  36.       EndProperty
  37.       Height          =   2775
  38.       Left            =   240
  39.       Locked          =   -1  'True
  40.       MultiLine       =   -1  'True
  41.       ScrollBars      =   3  'Both
  42.       TabIndex        =   6
  43.       Top             =   3480
  44.       Width           =   6495
  45.    End
  46.    Begin VB.ComboBox Combo2 
  47.       Height          =   315
  48.       Left            =   1320
  49.       TabIndex        =   0
  50.       Text            =   "Combo2"
  51.       Top             =   480
  52.       Width           =   3615
  53.    End
  54.    Begin VB.CommandButton Command1 
  55.       Caption         =   "Who Is"
  56.       Default         =   -1  'True
  57.       Height          =   375
  58.       Left            =   5040
  59.       TabIndex        =   2
  60.       Top             =   120
  61.       Width           =   1575
  62.    End
  63.    Begin VB.ComboBox Combo1 
  64.       Height          =   315
  65.       Left            =   1320
  66.       Style           =   2  'Dropdown List
  67.       TabIndex        =   1
  68.       Top             =   120
  69.       Width           =   3615
  70.    End
  71.    Begin VB.Label Label8 
  72.       Caption         =   "To query a specific handle, preface the query with the ""!"" character, such as: !MABRY-DOM."
  73.       Height          =   375
  74.       Left            =   240
  75.       TabIndex        =   12
  76.       Top             =   1080
  77.       Width           =   5655
  78.    End
  79.    Begin VB.Label Label7 
  80.       Caption         =   $"WhoCOM5.frx":0000
  81.       Height          =   615
  82.       Left            =   240
  83.       TabIndex        =   11
  84.       Top             =   1560
  85.       Width           =   6015
  86.    End
  87.    Begin VB.Label Label6 
  88.       Caption         =   $"WhoCOM5.frx":00C8
  89.       Height          =   495
  90.       Left            =   240
  91.       TabIndex        =   10
  92.       Top             =   2760
  93.       Width           =   6015
  94.    End
  95.    Begin VB.Label Label5 
  96.       Caption         =   $"WhoCOM5.frx":0166
  97.       Height          =   495
  98.       Left            =   240
  99.       TabIndex        =   9
  100.       Top             =   2280
  101.       Width           =   6135
  102.    End
  103.    Begin VB.Label Label4 
  104.       Caption         =   "Status:"
  105.       Height          =   255
  106.       Left            =   240
  107.       TabIndex        =   7
  108.       Top             =   6360
  109.       Width           =   735
  110.    End
  111.    Begin VB.Label Label3 
  112.       Caption         =   "Select a pre-defined Query value, or type one in."
  113.       Height          =   255
  114.       Left            =   240
  115.       TabIndex        =   5
  116.       Top             =   840
  117.       Width           =   4215
  118.    End
  119.    Begin VB.Line Line1 
  120.       X1              =   240
  121.       X2              =   6720
  122.       Y1              =   3360
  123.       Y2              =   3360
  124.    End
  125.    Begin VB.Label Label2 
  126.       Alignment       =   1  'Right Justify
  127.       Caption         =   "WhoIs Query:"
  128.       Height          =   255
  129.       Left            =   120
  130.       TabIndex        =   4
  131.       Top             =   480
  132.       Width           =   1095
  133.    End
  134.    Begin VB.Label Label1 
  135.       Alignment       =   1  'Right Justify
  136.       Caption         =   "WhoIs Server:"
  137.       Height          =   255
  138.       Left            =   120
  139.       TabIndex        =   3
  140.       Top             =   120
  141.       Width           =   1095
  142.    End
  143. End
  144. Attribute VB_Name = "Form1"
  145. Attribute VB_GlobalNameSpace = False
  146. Attribute VB_Creatable = False
  147. Attribute VB_PredeclaredId = True
  148. Attribute VB_Exposed = False
  149. Option Explicit
  150. Dim WithEvents WhoisX As WhoisXCom
  151. Attribute WhoisX.VB_VarHelpID = -1
  152. Implements IWhoisXComNotify
  153.  
  154. Private Sub Check1_Click()
  155.     If Check1.Value = vbChecked Then
  156.         'if the user enables Fast Notifications
  157.         'have the object pass the notifications
  158.         'directly to the form
  159.         Check1.Enabled = False
  160.         WhoisX.NotificationObject = Me
  161.     End If
  162. End Sub
  163.  
  164. Private Sub Command1_Click()
  165.     On Error Resume Next
  166.     'bail, if no query is set
  167.     If Combo1.Text = "" Then
  168.         Exit Sub
  169.     End If
  170.         
  171.     'peel the description from the name
  172.     'server
  173.     WhoisX.Host = Left$(Combo1.Text, InStr(Combo1.Text, " ") - 1)
  174.     '
  175.     'set the Query
  176.     WhoisX.Query = Combo2.Text
  177.     '
  178.     'set a Timeout
  179.     WhoisX.Timeout = 5
  180.     '
  181.     'non-blocking mode
  182.     WhoisX.Blocking = False
  183.     '
  184.     'clear the old results
  185.     Text1.Text = ""
  186.     'clear the progress list
  187.     List1.Clear
  188.     '
  189.     'get the results
  190.     Command1.Enabled = False
  191.     MousePointer = 11
  192.     'perform the query
  193.     WhoisX.GetWhoIs
  194.     If Err.Number <> 0 Then
  195.         List1.AddItem CStr(Err.Number)
  196.         Command1.Enabled = True
  197.         MousePointer = 0
  198.     End If
  199. End Sub
  200.  
  201. Private Sub Form_Load()
  202.     'create the object
  203.     Set WhoisX = New WhoisXCom
  204.     'load some database servers
  205.     Combo1.AddItem "whois.internic.net - North American domains"
  206.     Combo1.AddItem "whois.nic.mil - Military domains"
  207.     Combo1.AddItem "whois.nic.gov - Government domains"
  208.     Combo1.AddItem "whois.arin.net - American Registry domains"
  209.     Combo1.AddItem "whois.ripe.net - European domains"
  210.     Combo1.AddItem "whois.apnic.net - Asia Pacific domains"
  211.     Combo1.ListIndex = 0
  212.     'pre-load some queries
  213.     Combo2.AddItem "mabry.com"
  214.     Combo2.AddItem "mabry"
  215.     Combo2.AddItem "@mabry"
  216.     Combo2.AddItem "james@mabry.com"
  217.     Combo2.AddItem "!MABRY-DOM"
  218.     Combo2.ListIndex = 0
  219. End Sub
  220.  
  221. Private Sub Form_Unload(Cancel As Integer)
  222.     'practice safe programming -- destroy the object when finished
  223.     On Error Resume Next
  224.     Set WhoisX = Nothing
  225. End Sub
  226.  
  227. Private Sub IWhoisXCOMNotify_Done(ByVal SocketObject As WhoisXObj.IWhoisXCom, ByVal LastMethod As WhoisXObj.MethodsEnum, ByVal ErrorCode As Integer)
  228.     Dim l As Long
  229.     '
  230.     'we are finished
  231.     If ErrorCode = 0 Then
  232.         'no error occurred, so we loop through
  233.         'the responses and display the results
  234.         For l = 0 To WhoisX.ResponseCount - 1
  235.             Text1.Text = Text1.Text & WhoisX.Response(l) & vbCrLf
  236.         Next l
  237.         List1.AddItem "Done"
  238.     Else
  239.         'some error occurred
  240.         Debug.Print CStr(Err.Number)
  241.         Debug.Print CStr(ErrorCode)
  242.         Debug.Print CStr(LastMethod)
  243.         List1.AddItem CStr(ErrorCode) & " " & Err.Description
  244.     End If
  245.     're-enable the button
  246.     Command1.Enabled = True
  247.     MousePointer = 0
  248. End Sub
  249.  
  250. Private Sub IWhoisXComNotify_StateChanged(ByVal WhoisObject As WhoisXObj.IWhoisXCom, ByVal OldState As WhoisXObj.StatesEnum, ByVal NewState As WhoisXObj.StatesEnum)
  251.     'keep the user informed as to
  252.     'what is transpiring
  253.     Select Case NewState
  254.         Case 0
  255.             List1.AddItem "No usable socket library loaded."
  256.         Case 1
  257.             List1.AddItem "Socket closed."
  258.         Case 2
  259.             List1.AddItem "Socket created."
  260.         Case 3
  261.             List1.AddItem "Connecting..."
  262.         Case 4
  263.             List1.AddItem "Connected to host."
  264.         Case 5
  265.             List1.AddItem "Waiting for response..."
  266.         Case 6
  267.             List1.AddItem "Retrieving response..."
  268.         Case 7
  269.